package com.nbsaas.boot.evaluate.rest.convert;

import com.nbsaas.boot.entity.evaluate.Evaluate;
import com.nbsaas.boot.evaluate.api.domain.request.EvaluateRequest;

import org.springframework.beans.BeanUtils;
import com.nbsaas.boot.rest.api.Converter;
import com.nbsaas.boot.utils.BeanDataUtils;
            import com.nbsaas.boot.entity.evaluate.EvaluateCatalog;
            import com.nbsaas.boot.jpa.data.entity.User;
            import com.nbsaas.boot.jpa.data.entity.User;
            import com.nbsaas.boot.jpa.data.entity.User;
            import com.nbsaas.boot.jpa.data.entity.User;

/**
* 评价请求对象转换成实体对象
*/

public class EvaluateEntityConvert  implements Converter<Evaluate, EvaluateRequest> {

    @Override
    public Evaluate convert(EvaluateRequest source) {
        Evaluate result = new Evaluate();
        BeanDataUtils.copyProperties(source, result);
                    if(source.getCreator()!=null){
                    User creator =new User();
                    creator.setId(source.getCreator());
                    result.setCreator(creator);
                    }
                    if(source.getCatalog()!=null){
                    EvaluateCatalog catalog =new EvaluateCatalog();
                    catalog.setId(source.getCatalog());
                    result.setCatalog(catalog);
                    }
                    if(source.getReplyUser()!=null){
                    User replyUser =new User();
                    replyUser.setId(source.getReplyUser());
                    result.setReplyUser(replyUser);
                    }
                    if(source.getAuditUser()!=null){
                    User auditUser =new User();
                    auditUser.setId(source.getAuditUser());
                    result.setAuditUser(auditUser);
                    }
                    if(source.getTargetUser()!=null){
                    User targetUser =new User();
                    targetUser.setId(source.getTargetUser());
                    result.setTargetUser(targetUser);
                    }
        return result;
    }
}

